home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Sample Code / Sample Editors⁄Viewers / Cappuccino / Source / CappuccinoContent.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-12-11  |  5.4 KB  |  235 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CappuccinoContent.h
  3.  
  4.     Contains:    Class to encapsulate the content of the Cappuccino part.
  5.  
  6.     Written by:    Troy Gaul
  7.     
  8.     Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  9. */
  10.  
  11. #ifndef _CAPPUCCINOCONTENT_
  12. #define _CAPPUCCINOCONTENT_
  13.  
  14. // -- Compiler/Preprocessor Switches --
  15.  
  16. #ifndef _COMPILERDEFS_
  17. #include "CompDefs.h"
  18. #endif
  19.  
  20. // -- OpenDoc Includes --
  21.  
  22. #ifndef _ODTYPES_
  23. #include <ODTypes.h>
  24. #endif
  25.  
  26. // -- Cappuccino Includes --
  27.  
  28. #ifndef _REFCOUNTED_
  29. #include "RefCounted.h"
  30. #endif
  31.  
  32. //------------------------------------------------------------------------------
  33. // Forward declarations
  34. //------------------------------------------------------------------------------
  35.  
  36. class Cappuccino;
  37. class CCappuccinoContent;
  38. class CSettings;
  39.  
  40. class ODStorageUnit;
  41.  
  42. //------------------------------------------------------------------------------
  43. // CCappuccinoContent
  44. //------------------------------------------------------------------------------
  45.  
  46. class CCappuccinoContent : public MRefCounted {
  47.  
  48.     friend ODBoolean operator == (const CCappuccinoContent& a, 
  49.                                   const CCappuccinoContent& b);
  50.  
  51. public:
  52.  
  53.     CCappuccinoContent(Cappuccino* part);
  54.     
  55.     virtual ~CCappuccinoContent();
  56.     
  57.     // -- I/O --
  58.     
  59.     void InitCappuccinoContent(Environment* ev);
  60.     
  61.     void InitCappuccinoContent(Environment* ev, StringPtr);
  62.     
  63.     void InitCappuccinoContent(Environment* ev, ODStorageUnit*);
  64.     
  65.     void InitByTranslating(Environment* ev, ODStorageUnit* su, ODValueType from,
  66.                            ODValueType to);
  67.  
  68.     void Prepare(Environment* ev, ODStorageUnit*,
  69.                  ODValueType preferredKind);
  70.  
  71.     void Externalize(Environment* ev, ODStorageUnit*, ODDraftKey, 
  72.                      ODValueType preferredKind = kODNULL);
  73.     
  74.     void ExternalizeOneKind(Environment* ev, ODStorageUnit*, ODDraftKey, 
  75.                             ODValueType kind);
  76.     
  77.     // -- Promises --
  78.     
  79.     void Promise(Environment* ev, ODStorageUnit*, ODDraftKey,
  80.                  ODBoolean isForClipboard, Cappuccino* part);
  81.                  
  82.     void Fulfill(Environment* ev, ODStorageUnit*, ODValueType);
  83.  
  84.     // -- Accessors --
  85.     
  86.     StringPtr GetString();
  87.     
  88.     ODBoolean IsEmpty();
  89.  
  90.     // -- Imaging --
  91.     
  92.     void Draw(Environment* ev, ODFacet* facet, CSettings* settings);
  93.     
  94.     // -- Static utility functions --
  95.     
  96.     // Kind support
  97.     
  98.     static ODBoolean IsKindSupported(Environment* ev, ODValueType);
  99.  
  100.     static ODBoolean HasSupportedKind(Environment* ev, ODStorageUnit*);
  101.     
  102.     static ODValueType RecoverKindPtr(Environment* ev, ODValueType valueType);
  103.     
  104.     // Fidelity ordering
  105.     
  106.     static ODValueType GetNextHighestFidelity(ODValueType currentKind = kODNULL);
  107.     
  108.     static ODValueType GetHighestFidelityKindSupported(Environment* ev,
  109.                                                        ODStorageUnit*);
  110.     
  111.     // I/O
  112.     
  113.     static ODValueType GetKindToInternalize(Environment* ev, ODStorageUnit*);
  114.     
  115.     // Determining supported content
  116.     
  117.     static ODBoolean HasValidContent(Environment* ev, ODStorageUnit*,
  118.                                      ODBoolean* requiresTranslation = kODNULL);
  119.  
  120.     static ODBoolean HasValidFile(Environment* ev, ODStorageUnit*);
  121.  
  122.     // Translation
  123.     
  124.     static ODBoolean CanTranslate(Environment* ev, ODStorageUnit*);
  125.  
  126.     static ODBoolean GetTranslateKinds(Environment* ev, ODStorageUnit*,
  127.                                        ODValueType* from = kODNULL,
  128.                                        ODValueType* to = kODNULL);
  129.     
  130.     // Operations
  131.  
  132.     static void DoSetTextDialog(Environment* ev, ODFrame* frame, Cappuccino* part,
  133.                                 CCappuccinoContent* currentContent);
  134.  
  135. protected:
  136.  
  137.     // -- I/O --
  138.  
  139.     void InternalizeCappuccinoKind(Environment* ev, ODStorageUnit*);
  140.     
  141.     void ExternalizeCappuccinoKind(Environment* ev, ODStorageUnit*);
  142.     
  143. #ifndef qSingleKindSupported
  144.     void InternalizeTextData(Environment* ev, ODStorageUnit*);
  145.     
  146.     void ExternalizeTextData(Environment* ev, ODStorageUnit*);
  147.  
  148.     void InternalizeTextFile(Environment* ev, ODStorageUnit*);
  149. #endif
  150.     
  151.     void InternalizeTranslatedData(Environment* ev, ODStorageUnit*);
  152.     
  153. private:
  154.  
  155.     Cappuccino*        fPart;
  156.     StringPtr        fString;
  157. };
  158.  
  159. ODBoolean operator == (const CCappuccinoContent& a, const CCappuccinoContent& b);
  160. ODBoolean operator != (const CCappuccinoContent& a, const CCappuccinoContent& b);
  161.  
  162. //------------------------------------------------------------------------------
  163. // CSettings
  164. //------------------------------------------------------------------------------
  165.  
  166. class CSettings : public MRefCounted {
  167.  
  168.     friend ODBoolean operator == (const CSettings& a, const CSettings& b);
  169.  
  170. public:
  171.  
  172.     CSettings(Cappuccino* part);
  173.     
  174.     ~CSettings();
  175.  
  176.     // -- I/O --
  177.     
  178.     void InitSettings(Environment* ev);
  179.     
  180.     void InitSettings(Environment* ev, ODStorageUnit*);
  181.     
  182.     void Externalize(Environment* ev, ODStorageUnit*);
  183.     
  184.     // -- Accessors --
  185.     
  186.     ODSShort GetTextFont();
  187.     
  188.     ODUShort GetTextSize();
  189.     
  190.     ODBoolean GetDoesDrawFrame();
  191.     
  192.     // -- Settings --
  193.     
  194.     static void DoSettingsDialog(Environment* ev, ODFrame* frame,
  195.                                  Cappuccino* part, CSettings* currentSettings);
  196.  
  197. protected:
  198.  
  199.     void UseDefaults();
  200.     
  201. private:
  202.  
  203.     Cappuccino*        fPart;
  204.     ODSShort        fTextFont;
  205.     ODUShort        fTextSize;
  206.     ODBoolean        fDrawFrame;
  207. };
  208.  
  209. ODBoolean operator == (const CSettings& a, const CSettings& b);
  210. ODBoolean operator != (const CSettings& a, const CSettings& b);
  211.  
  212. //==============================================================================
  213. // Inlines
  214. //==============================================================================
  215.  
  216. //------------------------------------------------------------------------------
  217. // CSettings
  218. //------------------------------------------------------------------------------
  219.  
  220. inline ODSShort CSettings::GetTextFont()
  221. {
  222.     return fTextFont; 
  223. }
  224.     
  225. inline ODUShort CSettings::GetTextSize()
  226. {
  227.     return fTextSize; 
  228. }
  229.     
  230. inline ODBoolean CSettings::GetDoesDrawFrame()
  231. {
  232.     return fDrawFrame; 
  233. }
  234.  
  235. #endif